package br.ufmt.controller;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.event.ActionEvent;

import org.primefaces.component.gmap.GMap;
import org.primefaces.component.gmap.GMapInfoWindow;
import org.primefaces.component.gmap.GMapRenderer;
import org.primefaces.event.map.OverlaySelectEvent;
import org.primefaces.model.map.DefaultMapModel;
import org.primefaces.model.map.LatLng;
import org.primefaces.model.map.MapModel;
import org.primefaces.model.map.Marker;

import br.ufmt.model.Noticia;
@ManagedBean
public class MapController implements Serializable {

	private MapModel simpleModel;
	
	private Marker marker;
	private double lat;      
    private double lng;
    private String titulo;
    public static List<Marker> marcadores = new ArrayList<Marker>();
    public static List<Noticia> noticias = new ArrayList<Noticia>();

	public MapController() {
		simpleModel = new DefaultMapModel();

	/*	// Shared coordinates
		LatLng coord1 = new LatLng(-15.613613,-56.072656);
		LatLng coord2 = new LatLng(-15.6045,-56.070875);
		LatLng coord3 = new LatLng(-15.610989,-56.065896);

		// Basic marker
		simpleModel.addOverlay(new Marker(coord1, "Noticia A", "igor.jpg"));
		simpleModel.addOverlay(new Marker(coord2, "Noticia B", "igor.jpg"));
		simpleModel.addOverlay(new Marker(coord3, "Noticia C", "igor.jpg"));*/
		

		for(Noticia n : noticias){
			  Marker m = new Marker(new LatLng(n.getLat(),n.getLng()),n.getId(),n);
			   
				marcadores.add(m);
				simpleModel.addOverlay(m);
			
			
			
		}		
	
	}
	
	public String getTitulo() {
		return titulo;
	}

	public void setTitulo(String titulo) {
		this.titulo = titulo;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLng() {
		return lng;
	}

	public void setLng(double lng) {
		this.lng = lng;
	}

	public MapModel getSimpleModel() {
		return simpleModel;
	}

	public Marker getMarker() {
		return marker;
	}
	

	public void onMarkerSelect(OverlaySelectEvent evt) {
		
	 this.marker=(Marker) evt.getOverlay(); 
	    
	    
	   
	}
	public void addMarker(ActionEvent actionEvent) {  

          
        
    }
	
}